package com.igoal.campaign.entity;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.compass.annotations.SearchableProperty;
import org.hibernate.annotations.Type;

import com.igoal.entity.Audit;
import com.igoal.entity.BaseObject;
import com.igoal.entity.DataStatus;

@Entity
@Table(name="campaign")
public class Campaign extends BaseObject implements Audit{
	private static final long serialVersionUID = 7199156606419070798L;
	
	private Long id;
	private String campaignName;
	private String url;
	private Date from;
	private Date to;
	private boolean usedUserDB;
	private boolean usedMarketingDB;
	private String emailTitleTemplate;
	private String emailBodyTemplate;
	private Date cdate;
	private Date mdate;
	private DataStatus status;
	
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column(name = "id", unique = true, nullable = false)
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	@Column(name="campaign_name", nullable=false)
	public String getCampaignName() {
		return campaignName;
	}

	public void setCampainName(String campainName) {
		this.campaignName = campainName;
	}

	@Column
	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	@Column
	public Date getFrom() {
		return from;
	}

	public void setFrom(Date from) {
		this.from = from;
	}

	@Column
	public Date getTo() {
		return to;
	}

	public void setTo(Date to) {
		this.to = to;
	}
	
	@Type(type = "yes_no")
	@Column(name="igoal_db", nullable=false)
	public boolean isUsedUserDB() {
		return usedUserDB;
	}

	public void setUsedUserDB(boolean useUserDB) {
		this.usedUserDB = useUserDB;
	}

	@Type(type = "yes_no")
	@Column(name="marketing_db", nullable=false)
	public boolean isUsedMarketingDB() {
		return usedMarketingDB;
	}

	public void setUsedMarketingDB(boolean useMarketingDB) {
		this.usedMarketingDB = useMarketingDB;
	}

	@Column(name="email_title_template", nullable=true)
	public String getEmailTitleTemplate() {
		return emailTitleTemplate;
	}

	public void setEmailTitleTemplate(String emailTitleTemplate) {
		this.emailTitleTemplate = emailTitleTemplate;
	}

	@Column(name="email_body_template", nullable=true)
	public String getEmailBodyTemplate() {
		return emailBodyTemplate;
	}

	public void setEmailBodyTemplate(String emailBodyTemplate) {
		this.emailBodyTemplate = emailBodyTemplate;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "cdate", nullable = false, length = 19)
	public Date getCreateDate() {
		return this.cdate;
	}

	public void setCreateDate(Date cdate) {
		this.cdate = cdate;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "mdate", nullable = false, length = 19)
	public Date getUpdateDate() {
		return this.mdate;
	}

	public void setUpdateDate(Date mdate) {
		this.mdate = mdate;
	}
	
	@Enumerated(EnumType.STRING)
	@Column(nullable=false, name="status")
	@SearchableProperty
	public DataStatus getStatus(){
		return status;
	}

	@Override
	public boolean equals(Object o) {
		return false;
	}

	@Override
	public int hashCode() {		
		return id.hashCode();
	}

	@Override
	public String toString() {
		return campaignName;
	}

	public void setStatus(DataStatus dataStatus) {
		this.status = dataStatus;
	}	
}
